#ifndef __INClogMgrh
#define __INClogMgrh
#include <map>
#include <memory>
#include <type.h>
#include <logFile.h>
#include <posix.h>

namespace Ilog
{
    using LogPtr = std::shared_ptr<LogFile>;
    using LogMap = std::map<int, LogPtr>;
    STATUS logInitial();
    STATUS logRelease();
    STATUS logModuleUnregister(int logInst);
    LogPtr logModuleGet(int logInst);
    STATUS forEachLogModule(FUNCPTR func, void *);
    STATUS logModuleRegister(int& logInst, const char*, int fileCnt = 10, int fileSize = 10, int level = LOG_LVL_INFO);
    STATUS logHexdump(int logInst, const char* name, uint8_t width, const char* buf, uint16_t size);
    #define logWrite(logInst, level, file, func, line, format, ...)             \
        do                                                                      \
        {                                                                       \
            auto logIter = Ilog::logModuleGet(logInst);                         \
            if (logIter != nullptr)                                             \
            {                                                                   \
                logIter->write(level, file, func, line, format, ##__VA_ARGS__); \
            }                                                                   \
        } while (0)

}; // namespace Ilog


#endif // __INClogMgrh
